package com.cmy.controller;
import com.cmy.pojo.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
public class AjaxController {

    @RequestMapping("/t1")
    public String test(){
        return "hello";
    }

    @RequestMapping("/in")
    public String inTOOUt(String indata){
        System.out.println("intoout:"+indata);
        return indata;
    }

    @RequestMapping("/t2")
    public List<User> test2(){
        List<User> users = new ArrayList<User>();
        users.add(new User(1,"void",18));
        users.add(new User(2,"cmy",20));

        return users;
    }

    @RequestMapping("/t3")
    public String test3(String name,String pwd){
        String msg = "";
        if (name!=null){
            if ("admin".equals(name)){
                msg="ok";
            }else {
                msg="failed";
            }
        }
        if (pwd!=null){
            if ("123456".equals(pwd)){
                msg="ok";
            }else {
                msg="failed";
            }
        }
        return msg;
    }
}

    